import { Fields, TableAction } from "@/types/public";
import { Button, Popconfirm, Space } from "antd";
import React from "react";
import { EditOutlined, DeleteOutlined } from "@ant-design/icons";

// 分组数据结构定义
export interface listMonitor {
  deviceId: number;
  deviceSn: number | null;
  statusText: string;
  protocolText: string;
  onlineTime: string;
}

export const createlistMonitorField = (
  tableAction: TableAction<listMonitor> = {},
  existinglistMonitors: listMonitor[] = [] // 已有分组数据用于父分组选择
): Fields[] => {
  // 生成父分组选项 (仅显示静态分组)

  return [
    {
      valueType: "number",
      inputType: "input",
      key: "deviceId",
      title: "序号",
      disabled: true,
      dataIndex: "deviceId",
      width: 100,
      isEdit: false,
      visible: true,
      rules: [{ required: true }],
    },
    {
      valueType: "string",
      inputType: "input",
      key: "deviceSn",
      title: "设备号SN",
      disabled: true,
      dataIndex: "deviceSn",
      width: 100,
      isEdit: false,
      visible: true,
      rules: [{ required: true }],
    },
    {
      valueType: "string",
      inputType: "input",
      key: "statusText",
      title: "状态",
      disabled: true,
      dataIndex: "statusText",
      width: 100,
      isEdit: false,
      visible: true,
      rules: [{ required: true }],
    },
    {
      valueType: "string",
      inputType: "input",
      key: "protocolText",
      title: "数据周期",
      disabled: true,
      dataIndex: "protocolText",
      width: 100,
      isEdit: false,
      visible: true,
      rules: [{ required: true }],
    },
    {
      valueType: "string",
      inputType: "input",
      key: "onlineTime",
      title: "最新上线时间",
      disabled: true,
      dataIndex: "onlineTime",
      width: 100,
      isEdit: false,
      visible: true,
      rules: [{ required: true }],
    },
    {
      title: "操作",
      key: "action",
      fixed: "right",
      width: 300,
      render: (_: any, record: listMonitor) => (
        <Space size="middle">
          <Button
            type="link"
            size="small"
            icon={<EditOutlined />}
            onClick={() => tableAction.edit?.(record)}
          >
            编辑
          </Button>
          <Button
            type="primary"
            size="small"
            onClick={() => tableAction.migrate?.(record)}
          >
            远程调试
          </Button>
        </Space>
      ),
    },
  ];
};
